home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 26.zip / BS1 part 26 / Aztec C v5.2a disk 4.adf / 204inc_i.lzh / exec / libraries.i < prev    next >
Text File  |  1991-03-14  |  4KB  |  131 lines

  1.     IFND    EXEC_LIBRARIES_I
  2. EXEC_LIBRARIES_I    SET    1
  3. **
  4. **    $Filename: exec/libraries.i $
  5. **    $Release: 2.04 $
  6. **    $Revision: 36.11 $
  7. **    $Date: 91/02/11 $
  8. **
  9. **    Definitions for use when creating or using Exec libraries
  10. **
  11. **    (C) Copyright 1985,1986,1987,1988,1989,1991 Commodore-Amiga, Inc.
  12. **        All Rights Reserved
  13. **
  14.  
  15.     IFND EXEC_NODES_I
  16.     INCLUDE "exec/nodes.i"
  17.     ENDC    ; EXEC_NODES_I
  18.  
  19.  
  20. *------ Special Constants ---------------------------------------
  21. LIB_VECTSIZE    EQU    6        ;Each library entry takes 6 bytes
  22. LIB_RESERVED    EQU    4        ;Exec reserves the first 4 vectors
  23. LIB_BASE    EQU    -LIB_VECTSIZE
  24. LIB_USERDEF    EQU    LIB_BASE-(LIB_RESERVED*LIB_VECTSIZE) ;First user func
  25. LIB_NONSTD    EQU    LIB_USERDEF
  26.  
  27.  
  28. *----------------------------------------------------------------
  29. *
  30. *   Library Definition Macros (for creating libraries)
  31. *
  32. *----------------------------------------------------------------
  33.  
  34. *------ LIBINIT initializes the base offset for using the "LIBDEF" macro:
  35. LIBINIT     MACRO   ; [baseOffset]
  36.         IFC     '\1',''
  37. COUNT_LIB   SET     LIB_USERDEF
  38.         ENDC
  39.         IFNC    '\1',''
  40. COUNT_LIB   SET     \1
  41.         ENDC
  42.         ENDM
  43.  
  44. *------ LIBDEF is used to define each library function entry:
  45. LIBDEF        MACRO   ;libraryFunctionSymbol
  46. \1        EQU     COUNT_LIB
  47. COUNT_LIB   SET     COUNT_LIB-LIB_VECTSIZE
  48.         ENDM
  49.  
  50. *------ FUNCDEF is used to parse library offset tables.  Many applications
  51. *------ need a special version of FUNCDEF - you provide your own macro
  52. *------ to match your needs.  Here is an example:
  53. *
  54. *    FUNCDEF         MACRO
  55. *    _LVO\1         EQU    FUNC_CNT
  56. *    FUNC_CNT     SET    FUNC_CNT-6    * Standard offset-6 bytes each
  57. *    FUNC_CNT     EQU    LIB_USERDEF    * Skip 4 standard vectors
  58. *             ENDM
  59.  
  60. *----------------------------------------------------------------
  61. *
  62. *   Standard Library Functions
  63. *
  64. *----------------------------------------------------------------
  65.  
  66.     LIBINIT LIB_BASE
  67.  
  68.     LIBDEF  LIB_OPEN
  69.     LIBDEF  LIB_CLOSE
  70.     LIBDEF  LIB_EXPUNGE ; must exist in all libraries
  71.     LIBDEF  LIB_EXTFUNC    ; for future expansion - must return zero.
  72.  
  73.  
  74. *----------------------------------------------------------------
  75. *
  76. *   Library Base Structure Definition
  77. *   Also used for Devices and some Resources
  78. *
  79. *----------------------------------------------------------------
  80.  
  81.  STRUCTURE LIB,LN_SIZE
  82.     UBYTE   LIB_FLAGS            ; see below
  83.     UBYTE   LIB_pad            ; must be zero
  84.     UWORD   LIB_NEGSIZE        ; number of bytes before LIB
  85.     UWORD   LIB_POSSIZE        ; number of bytes after LIB
  86.     UWORD   LIB_VERSION        ; major
  87.     UWORD   LIB_REVISION        ; minor
  88.     APTR    LIB_IDSTRING        ; ASCII identification
  89.     ULONG   LIB_SUM            ; the system-calculated checksum
  90.     UWORD   LIB_OPENCNT        ; number of current opens
  91.     LABEL   LIB_SIZE    ;Warning: Size is not a longword multiple!
  92.  
  93. *------ LIB_FLAGS bit definitions (all others are system reserved)
  94.     BITDEF  LIB,SUMMING,0  ; system is currently checksumming
  95.     BITDEF  LIB,CHANGED,1  ; something has changed the library since last sum
  96.     BITDEF  LIB,SUMUSED,2  ; indicates if the library allows checksumming
  97.     BITDEF  LIB,DELEXP,3   ; delayed expunge flag (for use by library)
  98.     BITDEF  LIB,EXP0CNT,4  ; special system expunge flag.
  99.  
  100.  
  101. *---------------------------------------------------------------------------
  102. *
  103. *    Function Invocation Macros (for calling existing, opened, libraries)
  104. *    Also see exec/macros.i
  105. *
  106. *---------------------------------------------------------------------------
  107.  
  108. *------ CALLLIB for calling functions where A6 is already correct:
  109.  
  110. CALLLIB     MACRO   ; functionOffset
  111.     IFGT NARG-1
  112.         FAIL    !!! CALLLIB MACRO - too many arguments !!!
  113.     ENDC
  114.         JSR     \1(A6)
  115.         ENDM
  116.  
  117.  
  118. *------ LINKLIB for calling functions where A6 is incorrect:
  119.  
  120. LINKLIB     MACRO   ; functionOffset,libraryBase
  121.     IFGT NARG-2
  122.         FAIL    !!! LINKLIB MACRO - too many arguments !!!
  123.     ENDC
  124.         MOVE.L  A6,-(SP)
  125.         MOVE.L  \2,A6
  126.         JSR     \1(A6)
  127.         MOVE.L  (SP)+,A6
  128.         ENDM
  129.  
  130.     ENDC    ; EXEC_LIBRARIES_I
  131.